package com.example.aaa_viewpager;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils.TruncateAt;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.Button;
import android.widget.TextView;

import com.example.bb_serch.R;

public class fragment1 extends Fragment 
{
	private Button btn_N;
	private Button btn_C;
	private Button btn_S;
	private Button btn_E;
	private TextView title;
	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		return inflater.inflate(R.layout.view1, container, false);
    }
	@Override
	public void onActivityCreated(Bundle savedInstanceState) 
	{
		super.onActivityCreated(savedInstanceState);
		initView();
		initHandler();
	}
	
	//點選地區 並將該地區的資料庫編號 給下頁呈現
	
	private void initHandler() 
	{
		
		btn_N.setOnClickListener(new View.OnClickListener()
		{
			
			@Override
			public void onClick(View v) 
			{
				// TODO Auto-generated method stub
				Intent it = new Intent();
				Bundle bundle = new Bundle();
				bundle.putInt("BB", 0);
				it.putExtras(bundle);
				it.setClass(getActivity(),N_Activity.class);
				fragment1.this.startActivity(it);
		

			}
		});
		
		btn_C.setOnClickListener(new View.OnClickListener()
		{
			
			@Override
			public void onClick(View v) 
			{
				// TODO Auto-generated method stub
				Intent it = new Intent();
				Bundle bundle = new Bundle();
				bundle.putInt("BB", 1);
				it.putExtras(bundle);
				it.setClass(getActivity(),N_Activity.class);
				fragment1.this.startActivity(it);
		

			}
		});
		
		btn_S.setOnClickListener(new View.OnClickListener()
		{
			
			@Override
			public void onClick(View v) 
			{
				// TODO Auto-generated method stub
				Intent it = new Intent();
				Bundle bundle = new Bundle();
				bundle.putInt("BB", 2);
				it.putExtras(bundle);
				it.setClass(getActivity(),N_Activity.class);
				fragment1.this.startActivity(it);
		

			}
		});
		btn_E.setOnClickListener(new View.OnClickListener()
		{
			
			@Override
			public void onClick(View v) 
			{
				// TODO Auto-generated method stub
				Intent it = new Intent();
				Bundle bundle = new Bundle();
				bundle.putInt("BB", 3);
				it.putExtras(bundle);
				it.setClass(getActivity(),N_Activity.class);
				fragment1.this.startActivity(it);
		

			}
		});
		
	}
	private void initView()
	{
		// TODO Auto-generated method stub
		btn_N = (Button)getActivity().findViewById(R.id.button1);
		btn_C = (Button)getActivity().findViewById(R.id.button2);
		btn_S = (Button)getActivity().findViewById(R.id.button3);
		btn_E = (Button)getActivity().findViewById(R.id.button4);
		
		//title = (TextView) getActivity().findViewById(R.id.run_title);
//		//設置跑馬燈式標題
		//title.setHorizontallyScrolling(true);
		//title.setMarqueeRepeatLimit(-1);
//		//String msg = "請點選一個區域‧‧‧";
//		//title.setText(msg);
//		title.setSingleLine(true);
//		title.setEllipsize(TruncateAt.MARQUEE);
//		title.setMarqueeRepeatLimit(-1);
	}
	
}